package design2.iterator.example;

import design2.iterator.example.profile.Profile;
import design2.iterator.example.social_networks.Facebook;
import design2.iterator.example.social_networks.LinkedIn;
import design2.iterator.example.social_networks.SocialNetwork;
import design2.iterator.example.spammer.SocialSpammer;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Demo {

	public static Scanner scanner=new Scanner(System.in);

	public static void main(String[] args) {
		System.out.println("选择社交网络的类型：");
		System.out.println("1. Facebook"); //facebook
		System.out.println("2. LinkedIn"); //领英

		String choice=scanner.nextLine();
		SocialNetwork network;
		if(choice.equals("2")){
			network=new LinkedIn(createTestProfiles());
		}else{
			network=new Facebook(createTestProfiles());
		}

		//根据用户选择的社交网络类型给朋友或同事发送邮件
		SocialSpammer socialSpammer=new SocialSpammer(network);
		//通过朋友迭代器给朋友发送邮件
		socialSpammer.sendSpamToFriends("anna.smith@bing.com",
				"嘿这是安娜的朋友乔希。你能帮我一个忙，喜欢这个帖子吗？?");
		//通过同事迭代器给同事发送邮件
		socialSpammer.sendSpamToCoworkers("anna.smith@bing.com",
				"嘿这是安娜的老板杰森。安娜告诉我你会对[链接]感兴趣");
	}

	public static List<Profile> createTestProfiles() {
		List<Profile> data = new ArrayList<Profile>();
		data.add(new Profile("anna.smith@bing.com", "Anna Smith", "friends:mad_max@ya.com", "friends:catwoman@yahoo.com", "coworkers:sam@amazon.com"));
		data.add(new Profile("mad_max@ya.com", "Maximilian", "friends:anna.smith@bing.com", "coworkers:sam@amazon.com"));
		data.add(new Profile("bill@microsoft.eu", "Billie", "coworkers:avanger@ukr.net"));
		data.add(new Profile("avanger@ukr.net", "John Day", "coworkers:bill@microsoft.eu"));
		data.add(new Profile("sam@amazon.com", "Sam Kitting", "coworkers:anna.smith@bing.com", "coworkers:mad_max@ya.com", "friends:catwoman@yahoo.com"));
		data.add(new Profile("catwoman@yahoo.com", "Liza", "friends:anna.smith@bing.com", "friends:sam@amazon.com"));
		return data;
	}
}
